package com.pda.gongpin.ui.home;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pda.gongpin.R;
import com.pda.gongpin.contract.HomeContract;
import com.pda.gongpin.presenter.HomePresenter;
import com.pda.gongpin.utils.UserUtils;
import com.pda.gongpin.view.pagerview.MenuPagerView;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class HomeFragment extends BaseMvpFragment<HomePresenter> implements HomeContract.View, OnRefreshListener, MenuPagerView.onItemClickListener {
    @BindView(R.id.iv_admin)
    ImageView ivAdmin;
    @BindView(R.id.tv_admin)
    TextView tvAdmin;
    @BindView(R.id.tv1)
    TextView tv1;
    @BindView(R.id.switch_warehouse)
    RelativeLayout switchWarehouse;
    @BindView(R.id.tv_total_location)
    TextView tvTotalLocation;
    @BindView(R.id.tv_used)
    TextView tvUsed;
    @BindView(R.id.tv_occupancy_rate)
    TextView tvOccupancyRate;
    @BindView(R.id.home_mpv)
    MenuPagerView homeMpv;

    List<String> list=new ArrayList<>();
    @Override
    public HomePresenter getPresenter() {
        return new HomePresenter();
    }


    @Override
    public int getViewId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initView() {
        tvAdmin.setText(UserUtils.getInstance().getUserBean().getUserName());
        presenter.getRouters();
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {
       // presenter.storageUseInfo();
       /* list.add(new BusinessEntity(getString(R.string.call_empty),0,R.mipmap.direct_putaway,AppActivityKey.CALLEMPTYACTIVITY));
        list.add(new BusinessEntity(getString(R.string.defective_out),1,R.mipmap.manual_pallet,AppActivityKey.DEFECTIVEMANAGEMENTACTIVITY));
        list.add(new BusinessEntity(getString(R.string.defective_manager),4,R.mipmap.manual_outbound,AppActivityKey.DEFECTIVEACTIVITY));
        list.add(new BusinessEntity(getString(R.string.machine_nereclaimer),2,R.mipmap.manual_inventory,AppActivityKey.MAACHINERECLAIMERACTIVITY));
        list.add(new BusinessEntity(getString(R.string.stay_quality),3,R.mipmap.quick_outbound,AppActivityKey.QUALITYACTIVITY));
        list.add(new BusinessEntity(getString(R.string.scan_query),4,R.mipmap.manual_outbound,AppActivityKey.SCANQUERYACTIVITY));
        list.add(new BusinessEntity(getString(R.string.trolley_unbind),4,R.mipmap.manual_outbound,AppActivityKey.TROLLEYUNBINDACTIVITY));
        list.add(new BusinessEntity(getString(R.string.move),4,R.mipmap.manual_outbound,AppActivityKey.SCATTEREDMOVEACTIVITY));
        list.add(new BusinessEntity(getString(R.string.work_abnormal),4,R.mipmap.manual_outbound,AppActivityKey.WORKABNORMALACTIVITY));
        list.add(new BusinessEntity(getString(R.string.take_material),4,R.mipmap.manual_outbound,AppActivityKey.RECLAIMERBACKACTIVITY));
        list.add(new BusinessEntity(getString(R.string.back_pallet),4,R.mipmap.manual_outbound,AppActivityKey.BACKPALLETACTIVITY));*/

        list.add("整托入库");
        list.add("发货");
        list.add("空托入库");
        list.add("空托出库");
        list.add("手工入库");
        list.add("手工出库");
        list.add("盘库");
        list.add("移库");
        list.add("手工搬运");
        list.add("置空置满");
        list.add("扫码查询");
        list.add("异常盘点");
        homeMpv.initData(list,3);
        homeMpv.setOnItemListener(this);
    }

  /*  @Override
    public void setStorageUseInfo(StorageInfoBean storageInfoBean) {
        smart.finishRefresh();
        tvTotalLocation.setText(getResources().getString(R.string.overall_seat) + storageInfoBean.getTotal());
        tvUsed.setText(getResources().getString(R.string.have_been_used) + storageInfoBean.getUsedNum());
        tvOccupancyRate.setText(getResources().getString(R.string.occupancy_rate) + storageInfoBean.getUsage());
    }*/

    @Override
    public void showMessage(String msg) {
        super.showMessage(msg);
        //smart.finishRefresh();
    }
    @Override
    public void onRefresh(RefreshLayout refreshLayout) {
        //presenter.storageUseInfo();
    }

    @OnClick({R.id.iv_admin, R.id.tv_admin})
    public void onViewClicked5(View view) {
/*
        ConfrimDialog confrimDialog = new ConfrimDialog(mContext, new ConfrimDialog.Onclick() {
            @Override
            public void onConfirm() {
                startIntent(AppActivityKey.LOGIN);
                finishActivity();-
            }
        });
        confrimDialog.show(getString(R.string.out_login));*/
    }

    @Override
    public void onClick(String businessEntity) {
        switch (businessEntity){
            case "整托入库":
                startIntent(AppActivityKey.FULLTRAYINLISTACTIVITY);
                break;
            case "发货":
                startIntent(AppActivityKey.SHIPMENTSLISTACTIVITY);
                break;
            case "空托入库":
                startIntent(AppActivityKey.EMPTYPALLETINACTIVITY);
                break;
            case "空托出库":
                startIntent(AppActivityKey.EMPTYPALLETOUTACTIVITY);
                break;
            case "手工入库":
                startIntent(AppActivityKey.HANDINGINLISTACTIVITY);
                break;
            case "手工出库":
                startIntent(AppActivityKey.HANDINGOUTLISTACTIVITY);
                break;
            case "盘库":
                startIntent(AppActivityKey.FULLINVENTORYLISTACTIVITY);
                break;
            case "移库":
                startIntent(AppActivityKey.FULLMOVEACTIVITY);
                break;
            case "手工搬运":
                startIntent(AppActivityKey.MANUALHANDLINGACTIVITY);
                break;
            case "置空置满":
                startIntent(AppActivityKey.SETEMPTYFULLACTIVITY);
                break;
            case "扫码查询":
                startIntent(AppActivityKey.SCANQUERYACTIVITY);
                break;
            case "异常盘点":
                startIntent(AppActivityKey.ABNORMALCHECKACTIVITY);
                break;
        }
    }



}
